from selenium import webdriver


class GetDriver:
    """浏览器驱动类"""

    driver = None

    @classmethod
    def get_driver(cls, driver_type="Chrome"):
        """
        获取对应浏览器驱动对象 单例模式
        :param driver_type: 浏览器驱动类型
        :return: 浏览器驱动对象
        """
        if cls.driver is None:

            if driver_type == "Chrome":
                cls.driver = webdriver.Chrome()

            elif driver_type == "Firefox":
                cls.driver = webdriver.Firefox()

            elif driver_type == "Edge":
                cls.driver = webdriver.Edge()

            else:
                raise "该浏览器驱动不存在！"

        cls.driver.maximize_window()

        return cls.driver
